//
//  Menu2ViewController.m
//  ZFHorizontalMenuView
//
//  Created by linzaifei on 2021/9/3.
//

#import "Menu2ViewController.h"
#import "ZFHorizontalMenuView.h"
#import "colors.h"
#import "ZFImageCollectionCell.h"
@interface Menu2ViewController ()<ZFHorizontalMenuViewDataSource,ZFHorizontalMenuViewDelegate>

@end

@implementation Menu2ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithHexLightColor:COLOR_BG darkColor:COLOR_BG];
    [self createView];
}

-(void)createView{
    ZFHorizontalMenuView *horizontalMenuView = [[ZFHorizontalMenuView alloc] init];
    horizontalMenuView.dataSource = self;
    horizontalMenuView.delegate = self;
    horizontalMenuView.minimumLineSpacing =20;
    horizontalMenuView.minimumInteritemSpacing =1;
//    horizontalMenuView.pageControlView.pageCurrentDotColor = [UIColor orangeColor];
//    horizontalMenuView.pageControlView.pageDotColor = [UIColor grayColor];
//    horizontalMenuView.pageControlView.pageControlStyle = ZFHorizontalMenuViewPageControlStyleAnimated;
//    horizontalMenuView.pageControlView.pageControlAliment = ZFHorizontalMenuViewPageControlAlimentCenter;
    horizontalMenuView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    [self.view addSubview:horizontalMenuView];

    horizontalMenuView.translatesAutoresizingMaskIntoConstraints = NO;
    
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[horizontalMenuView]-0-|" options:0 metrics:0 views:@{@"horizontalMenuView":horizontalMenuView}]];
    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:horizontalMenuView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:100]];
    [horizontalMenuView reloadData];
}
///需要显示的个数
- (NSInteger)zf_horizontalMenuView:(ZFHorizontalMenuView *)horizontalMenuView{
    return 20;
}
////对应每一个title
-(NSString *)zf_horizontalMenuView:(ZFHorizontalMenuView *)horizontalMenuView titleForItemAtIndex:(NSInteger)index{
    return @"测试数据";
}

- (UIImage *)zf_horizontalMenuView:(ZFHorizontalMenuView *)horizontalMenuView imageForItemAtIndex:(NSInteger)index{
    return [UIImage imageNamed:@"ic_sign_qb"];
}

-(NSInteger )zf_numOfPageRowsInHorizontalMenuView:(ZFHorizontalMenuView *)horizontalMenuView{
    return 2;
}
-(NSInteger )zf_numOfPageColumnsInHorizontalMenuView:(ZFHorizontalMenuView *)horizontalMenuView{
    return 4;
}

-(void)zf_horizontalMenuView:(ZFHorizontalMenuView *)horizontalMenuView didSelectItemAtIndexPath:(NSInteger )index{
    NSLog(@"%ld",index);
}


- (Class)zf_customCollectionViewCellClassForHorizontalMenuView:(ZFHorizontalMenuView *)view{
    return [ZFImageCollectionCell class];
}
- (void)zf_setCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index horizontalMenuView:(ZFHorizontalMenuView *)view{
    
    ZFImageCollectionCell *cycleCell = (ZFImageCollectionCell *)cell;
   
}


@end
